{smcl}
{com}{sf}{ul off}{txt}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\thies\OneDrive\00_Promotion\00_Output\00_Paper\2022_Predicting_Econ_Sanctions\Empirics\20231214_Replication\Log_files/01a_Imposition_limited_sample_EU.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res}18 Dec 2023, 16:01:15
{txt}
{com}. 
. ***************************************************************
. ***EU***
. ***************************************************************
. 
. set seed 1234
{txt}
{com}. 
. * Install packages
. ssc install "brglm"
{txt}checking {hilite:brglm} consistency and verifying not already installed...
all files already exist and are up to date.

{com}. ssc install "outreg2"
{txt}checking {hilite:outreg2} consistency and verifying not already installed...
all files already exist and are up to date.

{com}. 
. *Prepare data
. use "Dataset.dta", clear
{txt}
{com}. keep if sender=="EU"
{txt}(10,154 observations deleted)

{com}. 
. ** Filter for cases of importance
. keep if pot_sanctioned_countries == 1
{txt}(1,296 observations deleted)

{com}. 
. gen ln_oil_gas_value_2014 = ln(oil_gas_value_2014+1)
{txt}(197 missing values generated)

{com}. gen sender_colony=0
{txt}
{com}. replace sender_colony=1 if ht_colonial==2 | ht_colonial==3 | ht_colonial==6 | ht_colonial==7 | ht_colonial==8 | ht_colonial==9 | ht_colonial==10
{txt}(2,539 real changes made)

{com}. 
. gen sender_additional=cond(threatUS==1 | impositionUS == 1, 1, 0)
{txt}
{com}. gen only_threat=cond(threatEU==1 & impositionEU == 0, 1, 0)
{txt}
{com}. 
. gen sender_trade = ln_EU_Trade_Eurostat
{txt}(20 missing values generated)

{com}. gen coup_dummy = coup1
{txt}(5 missing values generated)

{com}. replace coup_dummy = 0 if coup_dummy == 1
{txt}(61 real changes made)

{com}. replace coup_dummy = 1 if coup_dummy == 2
{txt}(45 real changes made)

{com}. 
. * Dependent variable : 1 if a threat or sanction case was ongoing in the dyad
. gen sanction_threat = sanction_dyad
{txt}
{com}. replace sanction_threat = 1 if threat_dyad==1
{txt}(49 real changes made)

{com}. tab sanction_threat

{txt}sanction_th {c |}
       reat {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
          0 {c |}{res}      3,299       87.25       87.25
{txt}          1 {c |}{res}        482       12.75      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}      3,781      100.00
{txt}
{com}. gen sanction_train= sanction_threat if year < 2009
{txt}(992 missing values generated)

{com}. gen sanction_test= sanction_threat if year >= 2009
{txt}(2,789 missing values generated)

{com}. 
. * lag time-series variables
. sort ccodecow year
{txt}
{com}. by ccodecow: gen l_v2x_polyarchy = v2x_polyarchy[_n-1] if year==year[_n-1]+1
{txt}(240 missing values generated)

{com}. by ccodecow: gen l_gd_ptss = gd_ptss[_n-1] if year==year[_n-1]+1
{txt}(225 missing values generated)

{com}. by ccodecow: gen l_coup_dummy = coup_dummy[_n-1] if year==year[_n-1]+1
{txt}(151 missing values generated)

{com}. by ccodecow: gen l_one_sided_violence = one_sided_violence[_n-1] if year==year[_n-1]+1
{txt}(147 missing values generated)

{com}. by ccodecow: gen l_conflict = conflict[_n-1] if year==year[_n-1]+1
{txt}(147 missing values generated)

{com}. by ccodecow: gen l_mid_terr_integrity = mid_terr_integrity[_n-1] if year==year[_n-1]+1
{txt}(147 missing values generated)

{com}. by ccodecow: gen l_ln_GDPpc_imputed = ln_GDPpc_imputed[_n-1] if year==year[_n-1]+1
{txt}(187 missing values generated)

{com}. by ccodecow: gen l_sender_trade = sender_trade[_n-1] if year==year[_n-1]+1
{txt}(165 missing values generated)

{com}. by ccodecow: gen l_ln_oil_gas_value = ln_oil_gas_value_2014[_n-1] if year==year[_n-1]+1
{txt}(202 missing values generated)

{com}. by ccodecow: gen l_defense_alliance = defense_alliance[_n-1] if year==year[_n-1]+1
{txt}(147 missing values generated)

{com}. 
. * create dummy variables
. tabulate l_gd_ptss, generate (pol_terr)

  {txt}l_gd_ptss {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
          1 {c |}{res}        465       13.08       13.08
{txt}          2 {c |}{res}      1,009       28.37       41.45
{txt}          3 {c |}{res}      1,190       33.46       74.92
{txt}          4 {c |}{res}        634       17.83       92.74
{txt}          5 {c |}{res}        258        7.26      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}      3,556      100.00
{txt}
{com}. 
. * sortieren nach Jahr, zur Vorbereitung RF model
. gen u=0
{txt}
{com}. replace u=1 if year >= 2009
{txt}(992 real changes made)

{com}. sort u
{txt}
{com}. 
. ** Imposition
. * Random Forest Model
. rforest sanction_threat l_v2x_polyarchy pol_terr* l_coup_dummy ///
> l_one_sided_violence l_conflict l_mid_terr_integrity ///
> l_ln_GDPpc_imputed l_sender_trade l_ln_oil_gas_value ///
> sender_colony l_defense_alliance in 1/2789, type(class) iter(1500) numvars(15)
{txt}
{com}. 
. *Variable Importance
. ereturn list

{txt}scalars:
       e(Observations) =  {res}2789
           {txt}e(features) =  {res}15
         {txt}e(Iterations) =  {res}1500
          {txt}e(OOB_Error) =  {res}.0735030476873431

{txt}macros:
                e(cmd) : "{res}rforest{txt}"
            e(predict) : "{res}randomforest_predict{txt}"
             e(depvar) : "{res}sanction_threat{txt}"
         e(model_type) : "{res}random forest classification{txt}"

matrices:
         e(importance) : {res} 15 x 1
{txt}
{com}. matrix list e(importance)
{res}
{txt}e(importance)[15,1]
              Variable I~e
l_v2x_poly~y {res}            1
{txt}   pol_terr1 {res}    .31603215
{txt}   pol_terr2 {res}    .54014694
{txt}   pol_terr3 {res}    .93031952
{txt}   pol_terr4 {res}    .97657524
{txt}   pol_terr5 {res}    .50912605
{txt}l_coup_dummy {res}    .38013267
{txt}l_one_side~e {res}    .27821133
{txt}  l_conflict {res}    .74716168
{txt}l_mid_terr~y {res}    .86582193
{txt}l_ln_GDPpc~d {res}    .82658364
{txt}l_sender_t~e {res}    .78566666
{txt}l_ln_oil_g~e {res}    .69662547
{txt}sender_col~y {res}    .15435309
{txt}l_defense_~e {res}     .3862294
{reset}
{com}. * write Variable importance to excel file
. putexcel set "Supplemental_Material\Variable_Importance\Variable_Importance_Imposition_EU_RF.xlsx", sheet("M") replace
{res}{txt}Note: File will be replaced when the first {cmd:putexcel} command is issued.

{com}. putexcel A1=matrix(e(importance)), names
{res}{txt}file {bf:Supplemental_Material\Variable_Importance\Variable_Importance_Imposition_EU_RF.xlsx} saved

{com}. 
. * Evaluation of model performance
. ** predictions
. predict randonsEU
{txt}
{com}. predict randonsEU0 randonsEU1, pr
{txt}
{com}. 
. * Confusion Matrix
. ** Sensitivity 68.2, Specificity 91.4
. tab2xl sanction_test randonsEU using Main_Article/EU_Imposition_RF_Confusion_Matrix, row(1) col(1)
{res}{txt}file {bf:Main_Article/EU_Imposition_RF_Confusion_Matrix.xlsx} saved

{com}. diagtest sanction_test randonsEU

{txt}sanction_t {c |}   predicted classes
       est {c |}         0          1 {c |}     Total
{hline 11}{c +}{hline 22}{c +}{hline 10}
         0 {c |}{res}       846         21 {txt}{c |}{res}       867 
{txt}         1 {c |}{res}        80         45 {txt}{c |}{res}       125 
{txt}{hline 11}{c +}{hline 22}{c +}{hline 10}
     Total {c |}{res}       926         66 {txt}{c |}{res}       992 

{txt}True D defined as randonsEU ~= 0                      [95% Conf. Inter.]
-------------------------------------------------------------------------
Sensitivity                     Pr( +| D)  {res}68.18%      65.28%   71.08%
{txt}Specificity                     Pr( -|~D)  {res}91.36%      89.61%   93.11%
{txt}Positive predictive value       Pr( D| +)  {res}36.00%      33.01%   38.99%
{txt}Negative predictive value       Pr(~D| -)  {res}97.58%      96.62%   98.53%
{txt}-------------------------------------------------------------------------
Prevalence                      Pr(D)      {res} 6.65%       5.10%    8.20%
{txt}-------------------------------------------------------------------------

{com}. 
. * AUPR .55
. prtab sanction_test randonsEU1, title("EU", box bexpand) l2title("Baseline model", box bexpand) 

{txt}{col 12}Number of observations       =  {res}992
{txt}{col 12}Unique values of classifier  =  {res}905
{txt}{col 12}Number of positive cases     =  {res}125
{txt}{col 12}Portion of positive cases    ={res}  0.1260

{txt}{hline 50}
{col 5} Recall =  0.1040{col 25}  0.2000{col 37}  0.3040
{hline 50}
{res}{col 2}Precision{col 14}  0.8667{col 25}  0.7813{col 37}  0.6909
{txt}{hline 50}
{res}
{txt}{col 2}Area under precision-recall curve:  0.5379

{com}. graph save "Graph" "Supplemental_Material\Prediction_Output\Roc-curves\AUPR_Imposition_RF_EU.gph", replace
{res}{txt}file {bf:Supplemental_Material\Prediction_Output\Roc-curves\AUPR_Imposition_RF_EU.gph} saved

{com}. 
. * .42
. kap sanction_test randonsEU

{txt}{col 14}Expected
Agreement   agreement     Kappa   Std. err.         Z      Prob>Z
{hline 65}
{res}  89.82%      82.42%     0.4208     0.0299      14.08      0.0000
{txt}
{com}. 
. *******************************************************************
. ******* Compare to logistic regression ability ********************
. *******************************************************************
. 
. sort ccodecow year
{txt}
{com}. egen sum_sanction = sum(sanction_dyad), by(ccodecow)
{txt}
{com}. gen dum_country = ccodecow
{txt}
{com}. replace dum_country = 0 if sum_sanction==0
{txt}(2,340 real changes made)

{com}. xtset ccodecow year
{res}
{col 1}{txt:Panel variable: }{res:ccodecow}{txt: (unbalanced)}
{p 1 16 2}{txt:Time variable: }{res:year}{txt:, }{res:{bind:1989}}{txt: to }{res:{bind:2015}}{p_end}
{txt}{col 10}Delta: {res}1 unit
{txt}
{com}. 
. * Original
. brglm sanction_train L.v2x_polyarchy i.L.gd_ptss i.L.coup_dummy i.L.one_sided_violence i.L.conflict i.L.mid_terr_integrity L.ln_GDPpc_imputed L.sender_trade L.ln_oil_gas_value_2014 i.L.sender_colony i.L.defense_alliance  i.dum_country i.year, vce(cluster ccodecow)
{res}{txt}Iteration 1    tol = {res}.01323081
{txt}Iteration 2    tol = {res}.07735895
{txt}Iteration 3    tol = {res}.19854972
{txt}Iteration 4    tol = {res}.30500691
{txt}Iteration 5    tol = {res}.19622322
{txt}Iteration 6    tol = {res}.04646519
{txt}Iteration 7    tol = {res}.00595682
{txt}Iteration 8    tol = {res}.00085109
{txt}Iteration 9    tol = {res}.00015575
{txt}Iteration 10    tol = {res}.00002994
{txt}Iteration 11    tol = {res}5.657e-06
{txt}Iteration 12    tol = {res}1.052e-06
{txt}Iteration 13    tol = {res}1.946e-07

{txt}Biased-reduced probit glm regression{col 51}No. of obs{col 67}={col 69}{res}     2,441


{txt}Log-likelihood: {res}-4993.7719

{txt}{hline 22}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12}
{col 1}       sanction_train{col 23}{c |} Coefficient{col 35}  Std. err.{col 47}      z{col 55}   P>|z|{col 63}     [95% con{col 76}f. interval]
{hline 22}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12}
{space 8}v2x_polyarchy {c |}
{space 18}L1. {c |}{col 23}{res}{space 2} -2.25383{col 35}{space 2} .6198909{col 46}{space 1}   -3.64{col 55}{space 3}0.000{col 63}{space 4}-3.468794{col 76}{space 3}-1.038867
{txt}{space 21} {c |}
{space 12}L.gd_ptss {c |}
{space 19}2  {c |}{col 23}{res}{space 2}-.0623384{col 35}{space 2} .3827992{col 46}{space 1}   -0.16{col 55}{space 3}0.871{col 63}{space 4}-.8126111{col 76}{space 3} .6879343
{txt}{space 19}3  {c |}{col 23}{res}{space 2} .4259607{col 35}{space 2} .4001413{col 46}{space 1}    1.06{col 55}{space 3}0.287{col 63}{space 4}-.3583018{col 76}{space 3} 1.210223
{txt}{space 19}4  {c |}{col 23}{res}{space 2} .6096761{col 35}{space 2} .4403365{col 46}{space 1}    1.38{col 55}{space 3}0.166{col 63}{space 4}-.2533675{col 76}{space 3}  1.47272
{txt}{space 19}5  {c |}{col 23}{res}{space 2} .7825962{col 35}{space 2} .5627507{col 46}{space 1}    1.39{col 55}{space 3}0.164{col 63}{space 4}-.3203749{col 76}{space 3} 1.885567
{txt}{space 21} {c |}
{space 9}L.coup_dummy {c |}
{space 19}1  {c |}{col 23}{res}{space 2} 1.735949{col 35}{space 2}  .268551{col 46}{space 1}    6.46{col 55}{space 3}0.000{col 63}{space 4} 1.209599{col 76}{space 3}   2.2623
{txt}{space 21} {c |}
{space 1}L.one_sided_violence {c |}
{space 19}1  {c |}{col 23}{res}{space 2} .2222287{col 35}{space 2} .2258154{col 46}{space 1}    0.98{col 55}{space 3}0.325{col 63}{space 4}-.2203614{col 76}{space 3} .6648189
{txt}{space 21} {c |}
{space 11}L.conflict {c |}
{space 19}1  {c |}{col 23}{res}{space 2} .3972596{col 35}{space 2} .1731303{col 46}{space 1}    2.29{col 55}{space 3}0.022{col 63}{space 4} .0579304{col 76}{space 3} .7365887
{txt}{space 21} {c |}
{space 1}L.mid_terr_integrity {c |}
{space 19}1  {c |}{col 23}{res}{space 2} .1318231{col 35}{space 2} .2148909{col 46}{space 1}    0.61{col 55}{space 3}0.540{col 63}{space 4}-.2893553{col 76}{space 3} .5530015
{txt}{space 21} {c |}
{space 5}ln_GDPpc_imputed {c |}
{space 18}L1. {c |}{col 23}{res}{space 2}-.1557269{col 35}{space 2} .1450879{col 46}{space 1}   -1.07{col 55}{space 3}0.283{col 63}{space 4} -.440094{col 76}{space 3} .1286401
{txt}{space 21} {c |}
{space 9}sender_trade {c |}
{space 18}L1. {c |}{col 23}{res}{space 2} .1157349{col 35}{space 2} .1130422{col 46}{space 1}    1.02{col 55}{space 3}0.306{col 63}{space 4}-.1058238{col 76}{space 3} .3372937
{txt}{space 21} {c |}
ln_oil_gas_value_2014 {c |}
{space 18}L1. {c |}{col 23}{res}{space 2}-.0010132{col 35}{space 2} .0187858{col 46}{space 1}   -0.05{col 55}{space 3}0.957{col 63}{space 4}-.0378327{col 76}{space 3} .0358063
{txt}{space 21} {c |}
{space 6}L.sender_colony {c |}
{space 19}1  {c |}{col 23}{res}{space 2} .7746516{col 35}{space 2} .1610008{col 46}{space 1}    4.81{col 55}{space 3}0.000{col 63}{space 4} .4590957{col 76}{space 3} 1.090207
{txt}{space 21} {c |}
{space 3}L.defense_alliance {c |}
{space 19}1  {c |}{col 23}{res}{space 2} .9185562{col 35}{space 2} .3060554{col 46}{space 1}    3.00{col 55}{space 3}0.003{col 63}{space 4} .3186987{col 76}{space 3} 1.518414
{txt}{space 21} {c |}
{space 10}dum_country {c |}
{space 18}40  {c |}{col 23}{res}{space 2} 1.049852{col 35}{space 2} .2078223{col 46}{space 1}    5.05{col 55}{space 3}0.000{col 63}{space 4} .6425275{col 76}{space 3} 1.457176
{txt}{space 18}41  {c |}{col 23}{res}{space 2} 2.457296{col 35}{space 2} .3019989{col 46}{space 1}    8.14{col 55}{space 3}0.000{col 63}{space 4} 1.865389{col 76}{space 3} 3.049203
{txt}{space 18}90  {c |}{col 23}{res}{space 2} .9414741{col 35}{space 2} .2923332{col 46}{space 1}    3.22{col 55}{space 3}0.001{col 63}{space 4} .3685116{col 76}{space 3} 1.514437
{txt}{space 18}91  {c |}{col 23}{res}{space 2} .9933886{col 35}{space 2} .3859972{col 46}{space 1}    2.57{col 55}{space 3}0.010{col 63}{space 4}  .236848{col 76}{space 3} 1.749929
{txt}{space 17}343  {c |}{col 23}{res}{space 2} 3.341603{col 35}{space 2} .3463239{col 46}{space 1}    9.65{col 55}{space 3}0.000{col 63}{space 4} 2.662821{col 76}{space 3} 4.020386
{txt}{space 17}344  {c |}{col 23}{res}{space 2} 3.817467{col 35}{space 2} .2642135{col 46}{space 1}   14.45{col 55}{space 3}0.000{col 63}{space 4} 3.299618{col 76}{space 3} 4.335316
{txt}{space 17}345  {c |}{col 23}{res}{space 2} 4.751843{col 35}{space 2} .2990888{col 46}{space 1}   15.89{col 55}{space 3}0.000{col 63}{space 4} 4.165639{col 76}{space 3} 5.338046
{txt}{space 17}346  {c |}{col 23}{res}{space 2} 4.374929{col 35}{space 2} .3316712{col 46}{space 1}   13.19{col 55}{space 3}0.000{col 63}{space 4} 3.724866{col 76}{space 3} 5.024993
{txt}{space 17}355  {c |}{col 23}{res}{space 2} 2.489864{col 35}{space 2} .2795106{col 46}{space 1}    8.91{col 55}{space 3}0.000{col 63}{space 4} 1.942033{col 76}{space 3} 3.037694
{txt}{space 17}360  {c |}{col 23}{res}{space 2} 1.737104{col 35}{space 2}  .266376{col 46}{space 1}    6.52{col 55}{space 3}0.000{col 63}{space 4} 1.215017{col 76}{space 3} 2.259191
{txt}{space 17}365  {c |}{col 23}{res}{space 2} 1.922948{col 35}{space 2}  .255788{col 46}{space 1}    7.52{col 55}{space 3}0.000{col 63}{space 4} 1.421612{col 76}{space 3} 2.424283
{txt}{space 17}369  {c |}{col 23}{res}{space 2} 1.249772{col 35}{space 2}  .167778{col 46}{space 1}    7.45{col 55}{space 3}0.000{col 63}{space 4} .9209336{col 76}{space 3} 1.578611
{txt}{space 17}370  {c |}{col 23}{res}{space 2} 3.526543{col 35}{space 2} .1489167{col 46}{space 1}   23.68{col 55}{space 3}0.000{col 63}{space 4} 3.234671{col 76}{space 3} 3.818414
{txt}{space 17}404  {c |}{col 23}{res}{space 2} 1.228001{col 35}{space 2} .3011087{col 46}{space 1}    4.08{col 55}{space 3}0.000{col 63}{space 4} .6378384{col 76}{space 3} 1.818163
{txt}{space 17}411  {c |}{col 23}{res}{space 2} 3.698504{col 35}{space 2} .2912604{col 46}{space 1}   12.70{col 55}{space 3}0.000{col 63}{space 4} 3.127644{col 76}{space 3} 4.269364
{txt}{space 17}420  {c |}{col 23}{res}{space 2} 2.643316{col 35}{space 2} .3147082{col 46}{space 1}    8.40{col 55}{space 3}0.000{col 63}{space 4} 2.026499{col 76}{space 3} 3.260133
{txt}{space 17}432  {c |}{col 23}{res}{space 2}-.2561546{col 35}{space 2} .5037665{col 46}{space 1}   -0.51{col 55}{space 3}0.611{col 63}{space 4}-1.243519{col 76}{space 3} .7312095
{txt}{space 17}435  {c |}{col 23}{res}{space 2}  .879364{col 35}{space 2} .3279419{col 46}{space 1}    2.68{col 55}{space 3}0.007{col 63}{space 4} .2366097{col 76}{space 3} 1.522118
{txt}{space 17}436  {c |}{col 23}{res}{space 2} 1.911663{col 35}{space 2} .3236881{col 46}{space 1}    5.91{col 55}{space 3}0.000{col 63}{space 4} 1.277246{col 76}{space 3}  2.54608
{txt}{space 17}437  {c |}{col 23}{res}{space 2} 1.838118{col 35}{space 2} .2169885{col 46}{space 1}    8.47{col 55}{space 3}0.000{col 63}{space 4} 1.412829{col 76}{space 3} 2.263408
{txt}{space 17}438  {c |}{col 23}{res}{space 2} 1.206851{col 35}{space 2} .3636524{col 46}{space 1}    3.32{col 55}{space 3}0.001{col 63}{space 4}  .494105{col 76}{space 3} 1.919596
{txt}{space 17}450  {c |}{col 23}{res}{space 2} 2.024865{col 35}{space 2} .4397059{col 46}{space 1}    4.61{col 55}{space 3}0.000{col 63}{space 4} 1.163057{col 76}{space 3} 2.886673
{txt}{space 17}451  {c |}{col 23}{res}{space 2}-.2461379{col 35}{space 2}  .307146{col 46}{space 1}   -0.80{col 55}{space 3}0.423{col 63}{space 4} -.848133{col 76}{space 3} .3558572
{txt}{space 17}461  {c |}{col 23}{res}{space 2}  3.53539{col 35}{space 2} .3335171{col 46}{space 1}   10.60{col 55}{space 3}0.000{col 63}{space 4} 2.881708{col 76}{space 3} 4.189071
{txt}{space 17}475  {c |}{col 23}{res}{space 2} 1.381622{col 35}{space 2} .2704022{col 46}{space 1}    5.11{col 55}{space 3}0.000{col 63}{space 4} .8516431{col 76}{space 3}   1.9116
{txt}{space 17}482  {c |}{col 23}{res}{space 2} .2385458{col 35}{space 2} .3513226{col 46}{space 1}    0.68{col 55}{space 3}0.497{col 63}{space 4}-.4500338{col 76}{space 3} .9271254
{txt}{space 17}484  {c |}{col 23}{res}{space 2} 1.542111{col 35}{space 2}  .226405{col 46}{space 1}    6.81{col 55}{space 3}0.000{col 63}{space 4} 1.098365{col 76}{space 3} 1.985856
{txt}{space 17}490  {c |}{col 23}{res}{space 2}  3.00817{col 35}{space 2} .3117015{col 46}{space 1}    9.65{col 55}{space 3}0.000{col 63}{space 4} 2.397247{col 76}{space 3} 3.619094
{txt}{space 17}516  {c |}{col 23}{res}{space 2}  1.29267{col 35}{space 2} .2947252{col 46}{space 1}    4.39{col 55}{space 3}0.000{col 63}{space 4}  .715019{col 76}{space 3}  1.87032
{txt}{space 17}517  {c |}{col 23}{res}{space 2}-.4220652{col 35}{space 2} .2261446{col 46}{space 1}   -1.87{col 55}{space 3}0.062{col 63}{space 4}-.8653004{col 76}{space 3} .0211701
{txt}{space 17}530  {c |}{col 23}{res}{space 2} 1.083134{col 35}{space 2} .3759566{col 46}{space 1}    2.88{col 55}{space 3}0.004{col 63}{space 4} .3462725{col 76}{space 3} 1.819995
{txt}{space 17}531  {c |}{col 23}{res}{space 2} .9590773{col 35}{space 2} .3362203{col 46}{space 1}    2.85{col 55}{space 3}0.004{col 63}{space 4} .3000978{col 76}{space 3} 1.618057
{txt}{space 17}552  {c |}{col 23}{res}{space 2} 2.308867{col 35}{space 2} .3466332{col 46}{space 1}    6.66{col 55}{space 3}0.000{col 63}{space 4} 1.629478{col 76}{space 3} 2.988255
{txt}{space 17}553  {c |}{col 23}{res}{space 2} 1.316083{col 35}{space 2} .3220876{col 46}{space 1}    4.09{col 55}{space 3}0.000{col 63}{space 4} .6848029{col 76}{space 3} 1.947363
{txt}{space 17}560  {c |}{col 23}{res}{space 2} 1.644499{col 35}{space 2} .4613965{col 46}{space 1}    3.56{col 55}{space 3}0.000{col 63}{space 4} .7401785{col 76}{space 3} 2.548819
{txt}{space 17}580  {c |}{col 23}{res}{space 2} .8207413{col 35}{space 2} .3668314{col 46}{space 1}    2.24{col 55}{space 3}0.025{col 63}{space 4}  .101765{col 76}{space 3} 1.539718
{txt}{space 17}615  {c |}{col 23}{res}{space 2} .5273033{col 35}{space 2}  .292426{col 46}{space 1}    1.80{col 55}{space 3}0.071{col 63}{space 4}-.0458412{col 76}{space 3} 1.100448
{txt}{space 17}620  {c |}{col 23}{res}{space 2} 3.343526{col 35}{space 2} .2038824{col 46}{space 1}   16.40{col 55}{space 3}0.000{col 63}{space 4} 2.943924{col 76}{space 3} 3.743128
{txt}{space 17}625  {c |}{col 23}{res}{space 2} 2.907985{col 35}{space 2} .2446725{col 46}{space 1}   11.89{col 55}{space 3}0.000{col 63}{space 4} 2.428436{col 76}{space 3} 3.387534
{txt}{space 17}630  {c |}{col 23}{res}{space 2} 1.621302{col 35}{space 2} .1786254{col 46}{space 1}    9.08{col 55}{space 3}0.000{col 63}{space 4} 1.271203{col 76}{space 3} 1.971401
{txt}{space 17}640  {c |}{col 23}{res}{space 2} .8898978{col 35}{space 2} .4055318{col 46}{space 1}    2.19{col 55}{space 3}0.028{col 63}{space 4} .0950701{col 76}{space 3} 1.684726
{txt}{space 17}651  {c |}{col 23}{res}{space 2}-.3994889{col 35}{space 2} .2456502{col 46}{space 1}   -1.63{col 55}{space 3}0.104{col 63}{space 4}-.8809545{col 76}{space 3} .0819766
{txt}{space 17}652  {c |}{col 23}{res}{space 2} 1.275682{col 35}{space 2} .1980124{col 46}{space 1}    6.44{col 55}{space 3}0.000{col 63}{space 4} .8875848{col 76}{space 3} 1.663779
{txt}{space 17}666  {c |}{col 23}{res}{space 2} 2.687245{col 35}{space 2} .4580386{col 46}{space 1}    5.87{col 55}{space 3}0.000{col 63}{space 4} 1.789506{col 76}{space 3} 3.584984
{txt}{space 17}700  {c |}{col 23}{res}{space 2} 1.471243{col 35}{space 2} .3135321{col 46}{space 1}    4.69{col 55}{space 3}0.000{col 63}{space 4} .8567319{col 76}{space 3} 2.085755
{txt}{space 17}702  {c |}{col 23}{res}{space 2}  2.35427{col 35}{space 2} .2564897{col 46}{space 1}    9.18{col 55}{space 3}0.000{col 63}{space 4} 1.851559{col 76}{space 3}  2.85698
{txt}{space 17}704  {c |}{col 23}{res}{space 2} 2.046439{col 35}{space 2} .2373769{col 46}{space 1}    8.62{col 55}{space 3}0.000{col 63}{space 4} 1.581189{col 76}{space 3} 2.511689
{txt}{space 17}710  {c |}{col 23}{res}{space 2} 4.062208{col 35}{space 2}  .439821{col 46}{space 1}    9.24{col 55}{space 3}0.000{col 63}{space 4} 3.200175{col 76}{space 3} 4.924241
{txt}{space 17}731  {c |}{col 23}{res}{space 2} 2.359671{col 35}{space 2} .3826935{col 46}{space 1}    6.17{col 55}{space 3}0.000{col 63}{space 4} 1.609606{col 76}{space 3} 3.109737
{txt}{space 17}775  {c |}{col 23}{res}{space 2} 3.143025{col 35}{space 2} .3185861{col 46}{space 1}    9.87{col 55}{space 3}0.000{col 63}{space 4} 2.518607{col 76}{space 3} 3.767442
{txt}{space 17}790  {c |}{col 23}{res}{space 2} 1.301978{col 35}{space 2} .2731489{col 46}{space 1}    4.77{col 55}{space 3}0.000{col 63}{space 4}  .766616{col 76}{space 3}  1.83734
{txt}{space 17}811  {c |}{col 23}{res}{space 2} .8409498{col 35}{space 2} .2638505{col 46}{space 1}    3.19{col 55}{space 3}0.001{col 63}{space 4} .3238123{col 76}{space 3} 1.358087
{txt}{space 17}850  {c |}{col 23}{res}{space 2}  .976973{col 35}{space 2} .2969796{col 46}{space 1}    3.29{col 55}{space 3}0.001{col 63}{space 4} .3949038{col 76}{space 3} 1.559042
{txt}{space 17}950  {c |}{col 23}{res}{space 2} 3.309269{col 35}{space 2} .4575308{col 46}{space 1}    7.23{col 55}{space 3}0.000{col 63}{space 4} 2.412525{col 76}{space 3} 4.206012
{txt}{space 21} {c |}
{space 17}year {c |}
{space 16}1991  {c |}{col 23}{res}{space 2} .7279107{col 35}{space 2} .3049448{col 46}{space 1}    2.39{col 55}{space 3}0.017{col 63}{space 4} .1302298{col 76}{space 3} 1.325592
{txt}{space 16}1992  {c |}{col 23}{res}{space 2} 1.073965{col 35}{space 2}   .32425{col 46}{space 1}    3.31{col 55}{space 3}0.001{col 63}{space 4} .4384467{col 76}{space 3} 1.709483
{txt}{space 16}1993  {c |}{col 23}{res}{space 2}  .901271{col 35}{space 2} .3405444{col 46}{space 1}    2.65{col 55}{space 3}0.008{col 63}{space 4} .2338164{col 76}{space 3} 1.568726
{txt}{space 16}1994  {c |}{col 23}{res}{space 2} .9042964{col 35}{space 2} .3598476{col 46}{space 1}    2.51{col 55}{space 3}0.012{col 63}{space 4}  .199008{col 76}{space 3} 1.609585
{txt}{space 16}1995  {c |}{col 23}{res}{space 2} .6914741{col 35}{space 2} .3993927{col 46}{space 1}    1.73{col 55}{space 3}0.083{col 63}{space 4}-.0913212{col 76}{space 3} 1.474269
{txt}{space 16}1996  {c |}{col 23}{res}{space 2} .7953933{col 35}{space 2} .4017743{col 46}{space 1}    1.98{col 55}{space 3}0.048{col 63}{space 4} .0079302{col 76}{space 3} 1.582856
{txt}{space 16}1997  {c |}{col 23}{res}{space 2} 1.106984{col 35}{space 2}  .403015{col 46}{space 1}    2.75{col 55}{space 3}0.006{col 63}{space 4} .3170892{col 76}{space 3} 1.896879
{txt}{space 16}1998  {c |}{col 23}{res}{space 2} 1.277925{col 35}{space 2} .3949565{col 46}{space 1}    3.24{col 55}{space 3}0.001{col 63}{space 4} .5038241{col 76}{space 3} 2.052025
{txt}{space 16}1999  {c |}{col 23}{res}{space 2} 1.495527{col 35}{space 2} .4213247{col 46}{space 1}    3.55{col 55}{space 3}0.000{col 63}{space 4} .6697462{col 76}{space 3} 2.321309
{txt}{space 16}2000  {c |}{col 23}{res}{space 2} 1.348463{col 35}{space 2} .4136139{col 46}{space 1}    3.26{col 55}{space 3}0.001{col 63}{space 4} .5377951{col 76}{space 3} 2.159132
{txt}{space 16}2001  {c |}{col 23}{res}{space 2}  1.38801{col 35}{space 2} .4041644{col 46}{space 1}    3.43{col 55}{space 3}0.001{col 63}{space 4} .5958625{col 76}{space 3} 2.180158
{txt}{space 16}2002  {c |}{col 23}{res}{space 2} 1.207002{col 35}{space 2} .4235923{col 46}{space 1}    2.85{col 55}{space 3}0.004{col 63}{space 4} .3767764{col 76}{space 3} 2.037228
{txt}{space 16}2003  {c |}{col 23}{res}{space 2} 1.293704{col 35}{space 2} .4197074{col 46}{space 1}    3.08{col 55}{space 3}0.002{col 63}{space 4} .4710929{col 76}{space 3} 2.116316
{txt}{space 16}2004  {c |}{col 23}{res}{space 2} 1.229394{col 35}{space 2} .4202874{col 46}{space 1}    2.93{col 55}{space 3}0.003{col 63}{space 4} .4056461{col 76}{space 3} 2.053142
{txt}{space 16}2005  {c |}{col 23}{res}{space 2} .9798745{col 35}{space 2} .4454278{col 46}{space 1}    2.20{col 55}{space 3}0.028{col 63}{space 4}  .106852{col 76}{space 3} 1.852897
{txt}{space 16}2006  {c |}{col 23}{res}{space 2} .9475158{col 35}{space 2} .4507221{col 46}{space 1}    2.10{col 55}{space 3}0.036{col 63}{space 4} .0641167{col 76}{space 3} 1.830915
{txt}{space 16}2007  {c |}{col 23}{res}{space 2} .6422175{col 35}{space 2} .4537935{col 46}{space 1}    1.42{col 55}{space 3}0.157{col 63}{space 4}-.2472014{col 76}{space 3} 1.531636
{txt}{space 16}2008  {c |}{col 23}{res}{space 2} .9717834{col 35}{space 2} .4467755{col 46}{space 1}    2.18{col 55}{space 3}0.030{col 63}{space 4} .0961194{col 76}{space 3} 1.847447
{txt}{space 21} {c |}
{space 16}_cons {c |}{col 23}{res}{space 2}-5.093695{col 35}{space 2} 1.808779{col 46}{space 1}   -2.82{col 55}{space 3}0.005{col 63}{space 4}-8.638838{col 76}{space 3}-1.548553
{txt}{hline 22}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12}

{com}. 
. predict onsEU_logistic
{txt}(407 missing values generated)

{com}. gen prob_sanc_onsEU_logistic = 1/(1+exp(-onsEU_logistic))
{txt}(407 missing values generated)

{com}. gen bin_prob_sanc_onsEU_logistic = cond(prob_sanc_onsEU_logistic > .5, 1,0)
{txt}
{com}. replace bin_prob_sanc_onsEU_logistic=. if missing(prob_sanc_onsEU_logistic)
{txt}(407 real changes made, 407 to missing)

{com}. tab sanction_test bin_prob_sanc_onsEU_logistic

           {txt}{c |} bin_prob_sanc_onsEU_l
sanction_t {c |}        ogistic
       est {c |}         0          1 {c |}     Total
{hline 11}{c +}{hline 22}{c +}{hline 10}
         0 {c |}{res}       802          9 {txt}{c |}{res}       811 
{txt}         1 {c |}{res}        93         29 {txt}{c |}{res}       122 
{txt}{hline 11}{c +}{hline 22}{c +}{hline 10}
     Total {c |}{res}       895         38 {txt}{c |}{res}       933 
{txt}
{com}. tab2xl sanction_test bin_prob_sanc_onsEU_logistic using Supplemental_Material\Prediction_Output\Confusion_Matrixes\EU_Imposition_PMLFE, col(1) row(1)
{res}{txt}file {bf:Supplemental_Material\Prediction_Output\Confusion_Matrixes\EU_Imposition_PMLFE.xlsx} saved

{com}. 
. *Evaluation
. * Sensitivity 76.3 Specificity 89.6
. diagtest sanction_test bin_prob_sanc_onsEU_logistic

           {txt}{c |} bin_prob_sanc_onsEU_l
sanction_t {c |}        ogistic
       est {c |}         0          1 {c |}     Total
{hline 11}{c +}{hline 22}{c +}{hline 10}
         0 {c |}{res}       802          9 {txt}{c |}{res}       811 
{txt}         1 {c |}{res}        93         29 {txt}{c |}{res}       122 
{txt}{hline 11}{c +}{hline 22}{c +}{hline 10}
     Total {c |}{res}       895         38 {txt}{c |}{res}       933 

{txt}True D defined as bin_prob_sanc_onsEU_logistic ~= 0   [95% Conf. Inter.]
-------------------------------------------------------------------------
Sensitivity                     Pr( +| D)  {res}76.32%      73.59%   79.04%
{txt}Specificity                     Pr( -|~D)  {res}89.61%      87.65%   91.57%
{txt}Positive predictive value       Pr( D| +)  {res}23.77%      21.04%   26.50%
{txt}Negative predictive value       Pr(~D| -)  {res}98.89%      98.22%   99.56%
{txt}-------------------------------------------------------------------------
Prevalence                      Pr(D)      {res} 4.07%       2.80%    5.34%
{txt}-------------------------------------------------------------------------

{com}. * kappa .32
. kap sanction_test bin_prob_sanc_onsEU_logistic

{txt}{col 14}Expected
Agreement   agreement     Kappa   Std. err.         Z      Prob>Z
{hline 65}
{res}  89.07%      83.92%     0.3203     0.0271      11.81      0.0000
{txt}
{com}. * AUPR .64
. prtab sanction_test prob_sanc_onsEU_logistic, title("EU", box bexpand) l2title("PML-FE", box bexpand)

{txt}{col 12}Number of observations       =  {res}933
{txt}{col 12}Unique values of classifier  =  {res}933
{txt}{col 12}Number of positive cases     =  {res}122
{txt}{col 12}Portion of positive cases    ={res}  0.1308

{txt}{hline 50}
{col 5} Recall =  0.1066{col 25}  0.2049{col 37}  0.3033
{hline 50}
{res}{col 2}Precision{col 14}  0.8125{col 25}  0.8065{col 37}  0.7255
{txt}{hline 50}
{res}
{txt}{col 2}Area under precision-recall curve:  0.6352

{com}. graph save "Graph" "Supplemental_Material\Prediction_Output\ROC-curves\AUPR_Imposition_PMLFE_EU.gph", replace
{res}{txt}file {bf:Supplemental_Material\Prediction_Output\ROC-curves\AUPR_Imposition_PMLFE_EU.gph} saved

{com}. 
. 
. * Random forest only for cases with data
. gen helper_sanction_test=sanction_test if!missing(prob_sanc_onsEU_logistic)
{txt}(2,848 missing values generated)

{com}. tab2xl helper_sanction_test randonsEU using Supplemental_Material\Prediction_Output\Confusion_Matrixes\EU_Imposition_RF_lim_sample, col(1) row(1)
{res}{txt}file {bf:Supplemental_Material\Prediction_Output\Confusion_Matrixes\EU_Imposition_RF_lim_sample.xlsx} saved

{com}. 
. * AUPR .54
. prtab helper_sanction_test randonsEU1, l2title("RF, sample limited", box bexpand) 

{txt}{col 12}Number of observations       =  {res}933
{txt}{col 12}Unique values of classifier  =  {res}855
{txt}{col 12}Number of positive cases     =  {res}122
{txt}{col 12}Portion of positive cases    ={res}  0.1308

{txt}{hline 50}
{col 5} Recall =  0.1066{col 25}  0.2049{col 37}  0.3033
{hline 50}
{res}{col 2}Precision{col 14}  0.8667{col 25}  0.8065{col 37}  0.7115
{txt}{hline 50}
{res}
{txt}{col 2}Area under precision-recall curve:  0.5373

{com}. graph save "Graph" "Supplemental_Material\Prediction_Output\ROC-curves\AUPR_Imposition_RF_EU_lim_sample", replace
{res}{txt}file {bf:Supplemental_Material\Prediction_Output\ROC-curves\AUPR_Imposition_RF_EU_lim_sample.gph} saved

{com}. 
. * kappa .42
. kap helper_sanction_test randonsEU

{txt}{col 14}Expected
Agreement   agreement     Kappa   Std. err.         Z      Prob>Z
{hline 65}
{res}  89.50%      81.86%     0.4210     0.0308      13.69      0.0000
{txt}
{com}. 
. * Sensitivity 68.8, Specificity 91
. diagtest helper_sanction_test randonsEU

{txt}helper_san {c |}   predicted classes
ction_test {c |}         0          1 {c |}     Total
{hline 11}{c +}{hline 22}{c +}{hline 10}
         0 {c |}{res}       791         20 {txt}{c |}{res}       811 
{txt}         1 {c |}{res}        78         44 {txt}{c |}{res}       122 
{txt}{hline 11}{c +}{hline 22}{c +}{hline 10}
     Total {c |}{res}       869         64 {txt}{c |}{res}       933 

{txt}True D defined as randonsEU ~= 0                      [95% Conf. Inter.]
-------------------------------------------------------------------------
Sensitivity                     Pr( +| D)  {res}68.75%      65.78%   71.72%
{txt}Specificity                     Pr( -|~D)  {res}91.02%      89.19%   92.86%
{txt}Positive predictive value       Pr( D| +)  {res}36.07%      32.98%   39.15%
{txt}Negative predictive value       Pr(~D| -)  {res}97.53%      96.54%   98.53%
{txt}-------------------------------------------------------------------------
Prevalence                      Pr(D)      {res} 6.86%       5.24%    8.48%
{txt}-------------------------------------------------------------------------

{com}. 
. log close
      {txt}name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\thies\OneDrive\00_Promotion\00_Output\00_Paper\2022_Predicting_Econ_Sanctions\Empirics\20231214_Replication\Log_files/01a_Imposition_limited_sample_EU.smcl
  {txt}log type:  {res}smcl
 {txt}closed on:  {res}18 Dec 2023, 16:02:34
{txt}{.-}
{smcl}
{txt}{sf}{ul off}